package last;

import java.util.*;

//TIP To <b>Run</b> code, press <shortcut actionId="Run"/> or
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        scanner.nextLine(); // 读取换行符
        String s = scanner.nextLine();
        int sLength = s.length();

        Set<String> passwords = new HashSet<>();
        for (int i = 0; i < n; i++) {
            String pwd = scanner.nextLine();
            passwords.add(pwd);
        }

        // 统计每个长度的密码数量
        Map<Integer, Integer> lengthCounts = new HashMap<>();
        for (String pwd : passwords) {
            int length = pwd.length();
            lengthCounts.put(length, lengthCounts.getOrDefault(length, 0) + 1);
        }

        // 计算长度小于正确密码的密码数量
        int numShorter = 0;
        for (Map.Entry<Integer, Integer> entry : lengthCounts.entrySet()) {
            if (entry.getKey() < sLength) {
                numShorter += entry.getValue();
            }
        }

        // 计算长度等于正确密码的密码数量
        int numEqual = lengthCounts.getOrDefault(sLength, 0);

        // 最少和最多尝试次数
        int minAttempts = numShorter + 1;
        int maxAttempts = numShorter + numEqual;

        System.out.println(minAttempts + " " + maxAttempts);
    }
}

